#!/usr/bin/bash

# 验证输入参数是否为空
if [ -z "$1" ] || [ -z "$2" ]; then
    echo "Usage: $0 <USERID> <USERNAME>"
    exit 1
fi

# 安全地获取 USERID 和 USERNAME
USERID=$1
USERNAME=$2

# 验证 USERID 是否为数字
if ! [[ "$USERID" =~ ^[0-9]+$ ]]; then
    echo "Error: USERID must be a number."
    exit 1
fi

# 构建 Docker Compose 服务
docker compose build --build-arg USERID="$USERID" --build-arg USERNAME="$USERNAME"

# 检查命令执行状态
if [ $? -ne 0 ]; then
    echo "Docker compose build failed."
    exit 1
fi

echo "Build completed successfully."